package cn.lingyangwl.agile.demo.mq_concurrence;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author shenguangyang
 */
@Component
public class MqConcurrenceRunner implements ApplicationRunner {
    @Resource
    private RabbitTemplate rabbitTemplate;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        for (int i = 0; i < 100; i++) {
            new Thread(() -> {
                rabbitTemplate.convertAndSend("test", "test", System.currentTimeMillis());
            }).start();
        }
    }
}
